package org.zwt.common.enumerate;

import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;


@AllArgsConstructor
@NoArgsConstructor
public enum HttpVersion {
    HTTP_0_9("HTTP/0.9"),
    HTTP_1_0("HTTP/1.0"),
    HTTP_1_1("HTTP/1.1"),
    HTTP_2_0("HTTP/2.0"),
    HTTP_3_0("HTTP/3.0");

    private String text;

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }
    /*
    * "HTTP/0.9" -> HttpVersion.HTTP_0_9
    * "http/0.9" -> HttpVersion.HTTP_0_9
    * */
    public static HttpVersion fromText(String text){
        for (HttpVersion v : HttpVersion.values()){
            if (v.getText().equalsIgnoreCase(text)){
                return v;
            }
        }
        return null;

    }
    @Override
    public String toString() {
        return this.text;
    }
}

